<?php
namespace app\mobile\controller;

use app\model\Record; 
use app\model\Util; 
use app\model\Theme; 
use app\model\Order; 

class Mypay extends Base
{
    public function Mypay()
    {
global $_G, $_P;
$op = !empty($_P['op']) ? $_P['op'] : 'display';
$system=$_G['system'];
$fans = $this->checkuser();
$themeid = intval($_P['themeid']);
if($themeid < 0){
	return_msg('活动入口不正确');
}
$recordid = intval($_P['recordid']);
$theme = Theme::getThemeById($themeid);
if(empty($theme['id'])){
    die(Util::showError("请确认活动地址是否正确"));
    return;
}

$config = 	Theme::getConfig($themeid);
$cachekey = 'theme'.$_G['mpid'].MODULE_NAME.'-'.$themeid;


//未支付的进行较验是否已支付
Order::checkorder($themeid,$config,$system);

$themyrecord = Record::getLastGroupByOpenId($_G['openid'],$themeid);
if(!empty($themyrecord)){
	if ($themyrecord['type']==1){
		$recordid = $themyrecord['pid'];
	}else{
		$recordid = $themyrecord['id'];
		$isleader = 1;
	}
	$themyrecordid = $recordid+1000;
}else{
	return_msg('未查到您的付款定单') ;
}

$themyorder = Order::getPayOrderByRIdZhifude($themyrecord['id']);

// $usernamelen=mb_strlen($themyrecord['username'],'utf-8');
// if ($usernamelen > 2){
// 	$themyrecord['username']=mb_substr($themyrecord['username'],0,1,'utf-8').'*'.mb_substr($themyrecord['username'],$usernamelen-1,1,'utf-8');
// }elseif (!empty($themyrecord['username'])){
// 	$themyrecord['username']='*'.mb_substr($themyrecord['username'],-1,1,'utf-8');
// }
$themyrecord['mobile']=mb_substr($themyrecord['mobile'],0,3,'utf-8').'****'.mb_substr($themyrecord['mobile'],$usernamelen-4,4,'utf-8');

$worker=db_find("SELECT * FROM ".tablename(t_worker)." WHERE uid = '{$themyrecord['workerid']}'");

$url =  "/". createMobileUrl('index',array('fopenid'=>$_G['openid'],'fromuid'=>$_G['member']['uid'],'workerid'=>$themyorder['workerid'],'themeid'=>$themyorder['themeid'],'recordid'=>$themyorder['masterid']));
if (intval($_P['showimg'])==1 && !empty($config['zhuandanimg'])) {
	$zhuandanimg = $config['zhuandanimg'];
}else{
	$zhuandanimg = '';
}

if ($system['qrlist']==1 && !empty($themyrecord['qrimg']) ) {
	$return_clicent = get_defined_vars();
return view('/base/paysuccess_qrlist', $return_clicent);
}else{
	if($_G['companyname'] =='飞驰软件'){
	$return_clicent = get_defined_vars();
return view('/fcpdd/paysuccess', $return_clicent);
	}else{
	$return_clicent = get_defined_vars();
return view('/base/paysuccess01', $return_clicent);
	}
}
}
}